﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DailyFx.AI
{

	public class SyntheticCondition : ICondition
	{
		private IList<ICondition> _children = new List<ICondition>();

		public SyntheticCondition ( ICondition condition)
		{ 
			this.and ( condition ) ;
		}

		public SyntheticCondition and ( ICondition condition)
		{
			if ( condition != null )
				this._children.Add (condition);
			
			return this;
		}

		public bool  Checks ( ITask task, IBlackboard blackboard)
		{
			foreach ( var c in this._children )
				if ( !c.Checks( task, blackboard) ) 
					return false;

			return true;
		}
	}
}
